<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/template/globalTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:define name="title">
        #{msg['application.titre.visitor.consulter']}
    </ui:define>

    <ui:define name="ariane">
        <h:commandLink action="/index.xhtml"  > Accueil </h:commandLink> > Sessions
    </ui:define>

    <ui:define name="content">

        <h:panelGroup styleClass="titre">Liste des sessions</h:panelGroup>


        <p:dataTable var="uneSession" value="#{visitorSessionBean.listSession}" widgetVar="informationTable">  
                
            <f:facet name="header">  
                <p:outputPanel>  
                    <h:outputText value="Recherche dans tous les champs:" />  
                    <p:inputText id="globalFilter" onkeyup="informationTable.filter()" style="width:150px" />  
                </p:outputPanel>  
            </f:facet>  

            <p:column style="width:16px">  
                <p:rowToggler />  
            </p:column>

            <p:column filterBy="#{uneSession.formation.domaine.libelle}"   
                      headerText="Domaine" >  
                <h:outputText value="#{uneSession.formation.domaine.libelle}" />  
            </p:column>  

            <p:column filterBy="#{uneSession.formation.libelle}"  
                      headerText="Formation" >  
                <h:outputText value="#{uneSession.formation.libelle}" />  
            </p:column>  

            <p:column   
                      headerText="Début" >  
                <h:outputText value="#{uneSession.dateDebut}">
                    <f:convertDateTime pattern="dd/MM/yy"/>
                </h:outputText>  
            </p:column>

            <p:column   
                      headerText="Fin" >  
                <h:outputText value="#{uneSession.dateFin}" >
                    <f:convertDateTime pattern="dd/MM/yy"/>
                </h:outputText>    
            </p:column>
            
            <p:column headerText="Inscription" >  
                <h:outputText value="Se connecter pour s'inscrire" rendered="#{!visitorSessionBean.activerLienInscription()}"/>
                
                <p:commandLink styleClass="lienAction lienCreer"  
                               value="#{msg['application.inscription']}"
                               action="#{visitorSessionBean.ouvrirPopupInscription(uneSession)}"
                               update="globalForm:popup"
                               rendered="#{visitorSessionBean.activerLienInscription()}"/>
            </p:column>
            
            <p:rowExpansion>  
                <h:panelGrid id="display" columns="4" cellpadding="4"  
                             style="width:500px;"  
                             styleClass="ui-widget-content"  
                             columnClasses="label, value">  
                    <h:graphicImage name="spacer.gif" library="images" width="50" height="1"/>
                    <p:dataTable value="#{uneSession.listSeance}" var="uneSeance" emptyMessage="#{msg['application.emptyMessage']}">
                        
                        <p:column headerText="Séance">
                            <h:outputText value="*" />
                        </p:column>
                        <p:column headerText="Date">
                            <h:outputText value="#{uneSeance.dateHeureDebut}">
                                <f:convertDateTime pattern="dd/MM/yy"/>
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Heure">
                            <h:outputText value="#{uneSeance.dateHeureDebut}">
                                <f:convertDateTime pattern="HH:mm"/>
                            </h:outputText>
                            -
                            <h:outputText value="#{uneSeance.dateHeureFin}">
                                <f:convertDateTime pattern="HH:mm"/>
                            </h:outputText>
                        </p:column>
                        <p:column headerText="Durée">
                            <h:outputText value="#{uneSeance.duree} h"/>
                        </p:column>
                        <p:column headerText="Salle">
                            <h:outputText value="#{uneSeance.session.salle.libPiece}"/>
                        </p:column>
                    </p:dataTable>

                </h:panelGrid>  

            </p:rowExpansion> 

        </p:dataTable>

    </ui:define>

    <ui:define name="popup">

        <h:panelGrid columns="2">
            <h:outputText value="Instructeur :"/>
            <h:outputText value="#{visitorSessionBean.session.instructeur}"/>
            <h:outputText value="Domaine :"/>
            <h:outputText value="#{visitorSessionBean.session.formation.domaine.libelle}"/>
            <h:outputText value="Formation :"/>
            <h:outputText value="#{visitorSessionBean.session.formation.libelle}"/>
            <p:selectOneMenu value="#{visitorSessionBean.personnel}"
                             converter="#{genericConverter}" 
                             id="inputInscription"
                             >
                <f:selectItems value="#{visitorSessionBean.listPersonnelSubordonne}" var="personnel" 
                               itemLabel="#{personnel.grade} #{personnel.nom}" id="selectPersonnel"/>
            </p:selectOneMenu>
            <h:outputText value=""/>
            <p:commandButton value="Inscrire"  
                             onclick="popup.hide()"
                             action="#{visitorSessionBean.inscrire()}"
                             update="messages"
                             />
            <p:commandButton value="Annuler" 
                             onclick="hide()"  
                             action="#{visitorSessionBean.annuler()}"
                             update="messages"/>
        
        </h:panelGrid>
    </ui:define>


</ui:composition>
